<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>给用户${(s_user.real_name)!''}绑定角色</title>
[#include "/admin/include/head.htm"]
<script type="text/javascript">
	var grid1, grid2;
	$(function () {
        grid1 = $("#maingrid1").ligerGrid({
            columns: [
			{name: 'id', hide: true, width:0, isAllowHide: false},
			{display: '商品名称', name: 'name', align: 'left', width: 200 },
			{display: '库存', name: 'stock', align: 'left', minWidth: 60 },
			{display: '是否上架', name: 'isMarketable', align: 'center', dict:'common', width: 60  }
			],  usePager:true, url: 'queryGoodsData.jhtml',
			toolbar: null, width: '100%', height:'100%', 
			title: "<img src='${base}/resource/images/communication.gif'>&nbsp;&nbsp;&nbsp;&nbsp;待选商品"
        });
        
		grid2 = $("#maingrid2").ligerGrid({
            columns: [
			{name: 'id', hide: true, width:0, isAllowHide: false},
			{display: '商品名称', name: 'goods.name', align: 'left', width: 200 },
			{display: '库存', name: 'goods.stock', align: 'left', minWidth: 60 }
			],  usePager:false, url: 'queryData.jhtml?storeId=' + getQueryStringByName("storeId"),
			toolbar: null, width: '100%', height:'100%', 
			title: "<img src='${base}/resource/images/communication.gif'>&nbsp;&nbsp;&nbsp;&nbsp;已关联商品"
        });


        //绑定搜索按钮
        LG.search(grid1);
    });
	
	/*function moveGoodsLeft() {
		var rows = grid2.getSelecteds();
		if (rows.length == 0) {
			LG.showError("请选择解绑商品!");
		}
		var goodsIds = new Array();
		for (var i = 0; i < rows.length; i++) {
			goodsIds.push(rows[i].id);
		}
		if(confirm('确认解绑商品', '您确定?')){
			LG.ajax({
				url : "moveGoodsLeft.jhtml",
				data : {"goodsIds": goodsIds, "storeId": getQueryStringByName("storeId")},
				success: function(){
					f_reload("maingrid1");
					f_reload("maingrid2");
				}
			});
		}
	}*/
	
	function moveGoodsRight() {
		var rows = grid1.getSelecteds();
		if (rows.length == 0) {
			LG.showError("请选择绑定商品!");
		}
		var goodsIds = new Array();
		for (var i = 0; i < rows.length; i++) {
			goodsIds.push(rows[i].id);
		}
		if(confirm('确认绑定', '您确定?')){
			LG.ajax({
				url : "moveGoodsRight.jhtml",
				data : {"goodsIds": goodsIds, "storeId": getQueryStringByName("storeId")},
				success: function(){
					f_reload("maingrid1");
					f_reload("maingrid2");
				}
			});
		}
	}
</script>
</head>
<body>
<div id="tabcontainer" style="margin:10px;">
	<div style="width:50%;float:left;">
        <div id="functions">
            <div class="clearfix">
                <div style="float:left;">
				<span>
					商品名称：<input type="text" class="formText" name="search_LIKE_name"/>
				</span>
				<input type="button" class="button" value="搜索" id="search"/>
				<a href="#" id="search_btn_reset" face="Wingdings 3">清除本次搜索</a>
                </div>
            </div>
        </div>
		<div id="maingrid1" style="margin:0; padding:0;"></div>
	</div>
	<div style="width:10%;float:left;vertical-align:middle;height:100%;top:50%;text-align:center;margin-top:200px;">
		<input value="绑定>>" type="button" onclick="moveGoodsRight();"/>
	</div>
	<div style="width:45%;float:left;">
		<div id="maingrid2" style="margin:0; padding:0;"></div>
	</div>
	<div style="clear:both;width:100%;height:0px;"></div>
</div>
</body>
</html>